#include "cmakedoc.h"
#include "qrcutil.h"

CMakeDoc::CMakeDoc()
{

}

QString CMakeDoc::name()
{
    return "CMake Doc";
}

QStringList CMakeDoc::searching(const QString &text)
{
    QStringList list;

    auto items = QR("://cmake-doc.txt").split("\n", Qt::SkipEmptyParts);
    foreach (auto var, items) {
        auto title = var.mid(var.lastIndexOf("/")+1);
        if (text.isEmpty()) {
            list << title;
        } else {
            if (title.contains(text, Qt::CaseInsensitive)) {
                list << title;
            }
        }
    }

    return list;
}

QString CMakeDoc::content(const QString &text)
{
    auto items = QR("://cmake-doc.txt").split("\n", Qt::SkipEmptyParts);
    foreach (auto var, items) {
        if (text.compare(var.mid(var.lastIndexOf("/")+1)) == 0) {
            return "file://" + var;
        }
    }
    return "";
}
